﻿using System;
using System.Web.Mvc;
using PhantomDb.Examples.Cruds;
using PhantomDb.Examples.Map;

namespace PhantomDb.MVC.Examples.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {

            ViewBag.Message = "Listado de usuarios y bancos.";

            try
            {

                var model = new Models.IndexModel();

                var usersCrud = C<UsersCrud>.Get();
                var banksCrud = C<BanksCrud>.Get();

                model.Users = usersCrud.List();
                model.Banks = banksCrud.List(Bank.T.Enabled + "=1");

                return View(model);
            }
            catch (Exception)
            {
                return RedirectToAction("Error");
            }

        }

        public ActionResult Error()
        {
            return View();
        }
    }
}
